package com.gszkc.mapper;

import com.gszkc.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.ArrayList;
import java.util.List;

@Mapper
public interface ShoppingCartMapper {

    /**
     * 动态查询购物车
     * @param shoppingCart
     * @return
     */
    List<ShoppingCart> list(ShoppingCart shoppingCart);

    @Update("update shopping_cart set number = #{number} where id =#{id}")
    void updateById(ShoppingCart shoppingCartTempData);

    /**
     * 插入购物车数据
     * @param shoppingCart
     */
    void insert(ShoppingCart shoppingCart);

    /**
     * 动态删除购物车数据
     * @param userId
     */
    @Delete("delete from shopping_cart where user_id = #{userId}")
    void deleteById(Long userId);

    /**
     * 修改购物车的份数
     * @param shoppingCart
     */
    @Update("update shopping_cart set number = #{number} where user_id = #{userId}")
    void updateNumberById(ShoppingCart shoppingCart);

    /**
     * 批量添加购物车
     * @param shoppingCartList
     */
    void insertBatch(ArrayList<ShoppingCart> shoppingCartList);
}
